#include "common_includes.h"
#include <string>
#include <map>
#include <sys/types.h>

//#include "ftp_user.h"
//#include "ftp_users_configuration_reader.h"

#ifndef FTPGROUP_H
#define FTPGROUP_H

AUTH_NS_START

class FtpUser; // Forward Declaration

/**
 * @class FtpGroup
 * @file ftp_group.h
 * @brief Group for securing FTP Access
 */
class FtpGroup {

private:
	/**
	 * Declaration. No definition to protect against copy replication
	 * @brief Disable Copy Construction
	 * @param rhs
	 */
	FtpGroup(const FtpGroup& rhs);

	/**
	 * @brief Disable Equal to Operator
	 * @param rhs
	 */
	FtpGroup& operator=(const FtpGroup& rhs);

protected:
	std::string m_sGroupName;
	gid_t m_sGid;

	// Map chosen for the datastructure as the inserts are few and lookups are more.
	// this makes lookups fast.
	typedef std::map<uid_t,std::string> UserListType;

	UserListType m_UserList;

public:

	/**
	 * @brief Registers a User to this Group
	 * @param user The User to be registered
	 */
	void RegisterUserInGroup(FtpUser* user);

	/**
	 * @brief Creates and initializes an instance of this class
	 * @param groupName The Readable name for the group
	 * @param gid The Group Id
	 */
	FtpGroup(std::string groupName, gid_t gid);

	/**
	 * @brief Virtual Destructor for clean inheritance cleanup
	 */
	virtual ~FtpGroup();

	/**
	 * @brief Gets the Group name
	 * @return Group Name
	 */
	const std::string& GetGroupName() const {
		return this->m_sGroupName;
	}

	/**
	 * @brief Gets the Group Id
	 * @return Group Id
	 */
	const gid_t GetGid() const {
		return this->m_sGid;
	}

	/**
	 * @brief Checks if the specified user is membery of the group
	 * @param user
	 * @return true if the user is a member, false otherwise
	 */
	bool IsUserMember(const FtpUser& user);

};

AUTH_NS_END

#endif // FTPGROUP_H
